package com.lct.demo;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        /**
         * 评委打分，0-100的整数，最终分为去掉最高最低后的平均分
         */
        double score = start(6);
        System.out.println("最终分数是" + score);

    }
    public static double start(int number){
        double[] scores = new double[number];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位评委的打分");
            double score = sc.nextDouble();
            if(score < 0 || score > 100){
                System.out.println("请您输入0-100之间的分数");
                i--;
                continue;
            }
            scores[i] = score;
        }
        double max = scores[0];
        double min = scores[0];
        double sum = scores[0];
        for (int i = 0; i < scores.length; i++) {
            double score = scores[i];
            if(score > max) max = score;
            if (score < min) min = score;
            sum += score;
        }

        return (sum - max - min) / (number - 2);
    }
}
